﻿using System.Text;

namespace DullBoard.Helper
{
    public static class StringExtender
    {

        public static string RemoveNonAscii(this string input)
        {
            return Encoding.ASCII.GetString(
                Encoding.Convert(
                    Encoding.UTF8,
                    Encoding.GetEncoding(
                        Encoding.ASCII.EncodingName,
                        new EncoderReplacementFallback(string.Empty),
                        new DecoderExceptionFallback()
                        ),
                    Encoding.UTF8.GetBytes(input)
                )
            );
        }
    }
}
